/*
 * @Author: Suo-Yuheng syh15399227325@163.com
 * @Date: 2025-09-23 17:55:11
 * @LastEditors: Suo-Yuheng syh15399227325@163.com
 * @LastEditTime: 2025-09-23 18:01:12
 * @FilePath: /0923/Reactor/Comm.hpp
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
 */
#pragma once

#include <unistd.h>
#include <fcntl.h>
#include <cstdlib>
#include "Socket.hpp"



void SetNonBlockOrDie(int fd)   // 将文件描述符 设置为非阻塞
{
    int fl = fcntl(fd, F_GETFL);
    if(fl < 0)
    {
        exit(NON_BLOCK_ERR);
    }
    fcntl(fd, F_SETFL, fl | O_NONBLOCK);
}